<?php
if(!defined('BZ_XTBLOG') || !defined('BZ_WJSCUZ')) {
	exit('Access Denied');
}
$wzxx_title ='网站合作-'.$wzxx_title.'';
$wzxx_gj    ='网站合作-'.$wzxx_gj.'';
$wzxx_ms    ='网站合作-'.$wzxx_ms.'';
$gid =verify_id($_GET['gid']);
if(Bingz_config('link_config_scsz') == '1'){
   $sql_li=$db->query('link'," `time_a`='0' ORDER BY `time_b` DESC LIMIT 0 , 10 ",'');
   while($row=mysql_fetch_array($sql_li)){
   	  $timesj=60*60*24*7;
   	  if( ($time - $row[time_b]) > $timesj ){
   	  	 $db->delete('link'," `id` = '$row[id]'");
   	  }
   }
}
if($gid){
   $db->update('link',array('jlick' => '+1' ,'time_a' => $time)," `id` ='$gid'");
   $pdid='1';
}else{
	$link_config_ts=Bingz_config('link_config_ts');
	
   $sql_lwi=$db->query('link'," `uid`= '$user_uid' ORDER BY `id` DESC",'');
   while($row=mysql_fetch_array($sql_lwi)){
   	  $rownamem=Bingz_html($row['namem']);
      $wodll[]= array('id' => $row['id'],'name' => $rownamem );
   }

   $sql_li=$db->query('link'," `check`='0' ORDER BY `time_a` DESC LIMIT 0 , $link_config_ts ",'');
   while($row=mysql_fetch_array($sql_li)){
   	  $rownamem=Bingz_html($row['namem']);
      $lisja[]= array('id' => $row['id'],'name' => $rownamem );
   }
   $sql_la=$db->query('link'," `type`='1' AND `check`='0' ORDER BY `time_a` DESC LIMIT 0 , $link_config_ts",'');
   while($row=mysql_fetch_array($sql_la)){
   	  $rownamem=Bingz_html($row['namem']);
      $lisjb[]= array('id' => $row['id'],'name' => $rownamem );
   }
   $sql_lb=$db->query('link'," `type`='2' AND `check`='0' ORDER BY `time_a` DESC LIMIT 0 , $link_config_ts",'');
   while($row=mysql_fetch_array($sql_lb)){
   	  $rownamem=Bingz_html($row['namem']);
      $lisjc[]= array('id' => $row['id'],'name' => $rownamem );
   }
   $sql_lc=$db->query('link'," `type`='3' AND `check`='0' ORDER BY `time_a` DESC LIMIT 0 , $link_config_ts",'');
   while($row=mysql_fetch_array($sql_lc)){
   	  $rownamem=Bingz_html($row['namem']);
      $lisjd[]= array('id' => $row['id'],'name' => $rownamem );
   }
   $sql_lc=$db->query('link'," `type`='4' AND `check`='0' ORDER BY `time_a` DESC LIMIT 0 , $link_config_ts",'');
   while($row=mysql_fetch_array($sql_lc)){
   	  $rownamem=Bingz_html($row['namem']);
      $lisxd[]= array('id' => $row['id'],'name' => $rownamem );
   }

   $sql_lk=$db->query('link_class'," `type`='0' ORDER BY `px` ",'');
   while($rowk=mysql_fetch_array($sql_lk)){
   	    $fl='';
        $sql_lc=$db->query('link'," `fid`='$rowk[id]' AND `check`='0' ORDER BY `jlick` DESC LIMIT 0 , 4",'');
        while($waa=mysql_fetch_array($sql_lc)){
   	        $waa['namem']=Bingz_html($waa['namem']);
	          $fl[]= array('id' => $waa[id] ,'name' => $waa[namem] ,'flid' => $waa[fid]);
        }
   	    $rowk['namem']=Bingz_html($rowk['namem']);
	      $lisj[]= array('id' => $rowk['id'],'name' => $rowk['name'],'ff' => $fl);
   }
}
@include template('head');
@include template('link/link_index');
@include template('foot');
?>